let that,
  api = new (require('../../utils/api.js')),
  headimg=api.getheadurl(),
  app=getApp(),
util = new (require('../../utils/util.js'));
Page({

  /**
   * 页面的初始数据
   */
  data: {
    myid:'',
    clickgood: !0,
    headimg,
    pagesize:12,
    start:0,
    data:{},
    id:0,
    isfollow:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  that = this;
  that.setData({
    myid:app.logininfo.userid
  })
  that.setData(
  {id:options.id})
  that.getdata(options.id);
  },


  getdata(userid){
    let {pagesize,start} = this.data;
      api.getusermainpage({pagesize,start,userid},res=>{
          let list=[];
          list=res.data.data;
          console.log(list,'afafafaf')
          list.comments.forEach((v,i)=>{
           let piclist = [];
           console.log(v.item.piclist,'afafafafaf')
           
           piclist=v.item.piclist.split(",");
            v.item.piclist = piclist;
            
            v.item.updateTime = util.myTime(v.item.updateTime)
          })
        let isfollow=res.data.data.isfollow==0?'+关注':'已关注';
          console.log(list,'mylisstsst')
          that.setData({
            data:list,
            isfollow
          })
      })
  },
 favor(e){
   console.log(e,'aaaa')
   let { id, isfavor} = e.currentTarget.dataset;
   api.dofavor(id,res=>{
     if(res.issuccess=1){
       if (isfavor==1){
         wx.showToast({
           title: '点赞成功',
         })
       }else{
         wx.showToast({
           title: '取消点赞',
         })
       }
     that.getdata(that.data.id)
     }
   })
 },
  follow(){
    let idolid=that.data.id;
    api.follow({idolid},res=>{
     if(res.issuccess=1)
       that.getdata(idolid)
    })
  },
  getfanslist(e){
    wx.navigateTo({
      url: '../fans/fans?id=' + e.currentTarget.dataset.id,
    })
  },
  getfollowlist(e){
    wx.navigateTo({
      url: '../follows/follows?id=' + e.currentTarget.dataset.id,
    })
  },

  /**
  * 跳转评论详情页
  */
  skip(e) {
    console.log(e, '111')
    let {id}=e.currentTarget.dataset;
      wx.navigateTo({
        url: '../sharedetail/sharedetail?id='+id,
      })
  

  },

  tabtap(e) {
    let {
      index
    } = e.currentTarget.dataset, {
      currentageindex
    } = this.data;
    if (index == currentageindex) {
      return;
    }
    this.setData({
      currentageindex: index,
      currentpage: 1,
      list: []
    })
    this.getdata(index, 0);
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})